import { regPhone, regSpecial } from "@/utils/validate";

export const addClientFormInit = {
  customerName: "",
  mobileCode: "",
  fitmentAreaIds: [],
  residence: "",
  buildingName: "",
  address: "",
  area: "",
  totalPriceLevel: "",
  totalPriceLevelName: "",
  fromType: "",
  fromTypeName: "",
  houseType: "",
  houseTypeName: "",
  fitment: [],
  fitmentName: "",
  businessType: "",
  businessTypeName: "",
  budget: "",
  budgetName: "",
  isFutures: "0",
  isFuturesName: "否",
  remark: "",
  deptId: "",
  businessUserId: "",
  businessUserName: "",
  portaintId: "",
  portaintName: "",
  fromDetailType: "",
  fromDetailTypeName: "",
  mobileCode1: "",
  mobileCode2: ""
};
const phoneValidator = (rule, value, callback) => {
  if (!regPhone(value)) {
    callback(new Error("手机号格式不正确"));
  } else {
    callback();
  }
};
const nameValidator = (rule, value, callback) => {
  if (!regSpecial(value)) {
    callback(new Error("不能包含特殊字符"));
  } else {
    callback();
  }
};
export const addClientFormRules = {
  customerName: [
    { required: true, message: "客户姓名不能为空", trigger: "blur" },
    { validator: nameValidator, message: "不能包含特殊字符", trigger: "blur" }
  ],
  mobileCode: [
    { required: true, message: "客户电话不能为空", trigger: "blur" },
    { validator: phoneValidator, message: "手机号格式不正确", trigger: "blur" }
  ],
  residence: { required: true, message: "请填写小区名称", trigger: "blur" },
  businessUserId: { required: true, message: "请选择业务人员", trigger: "change" },
  deptId: { required: true, message: "请选择业务人员部门", trigger: "change" },
  portaintId: { required: true, message: "请选择业务类型", trigger: "change" }
};
